package com.offcn.service;

import com.offcn.dao.UserDao;
import com.offcn.dao.daoimpl.UserDaoImpl;
import com.offcn.pojo.User;
import com.offcn.util.PageUtil;

import java.util.List;
import java.util.Map;

public class UserService {
    private UserDao userDao = new UserDaoImpl();

    public User login(String username,String password) {
        return userDao.login(username,password);
    }

    public int addUser(User map) {
        return userDao.addUser(map);
    }

    //分页查询
    public PageUtil<User> queryUserByPage(String currentPage, String pageSize, String search) {
        //查询用户总条数
        Integer totalCount = userDao.queryCount(search);
        //创建分页对象
        PageUtil<User> pageUtil=new PageUtil<>(totalCount,currentPage,Integer.valueOf(pageSize));
        //分页查询用户
        List<User> userList =  userDao.queryUserByPage(pageUtil,search);
        //分页对象设置集合
        pageUtil.setList(userList);
        return pageUtil;
    }

    public int deleteUserByIds(String ids) {
        return userDao.deleteUserByIds(ids);
    }

    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    public User checkPhone(String phone) {
        return userDao.checkPhone(phone);
    }
    /*用户注册*/
    public int register(String name, String phone, String pwd) {
        return userDao.register(name,phone,pwd);
    }
    /*手机登录*/
    public User loginByPhone(String phone, String pwd) {
        return userDao.loginByPhone(phone,pwd);
    }
    /*获取登录人信息*/
}
